// <copyright file="EasyWebApp.cs" company="<Customer Name>">This is a "work-for-hire". or Copyright (C) 2010 MicroCODE Incorporated Troy, MI</copyright><author><Class Author's Name></author>

/*
 *      Title:    <Class Description>
 *      Module:   ClassTemplate (<Namespace>:ClassTemplate.cs)
 *      Project:  <Project Name>
 *      Customer: <Customer Name>
 *      Facility: MicroCODE Incorporated
 *      Date:     <Class Creation Date>
 *      Author:   <Class Author's Name>
 * 
 * 
 * 
 *  
 *      MODIFICATIONS:
 *      --------------
 *
 *  Date:         By-Group:   Rev:     Description:
 *
 *  DD-Mmm-YYYY   XYZ-GROUP  {0001}    Describe reason for creating or modifying class... 
 * 
 * 
 * 
 */
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using Org.EasyWeb.Sys;
using Org.EasyWeb.SysUtil;

namespace Org.EasyWeb.Application
{
    internal class AppToolkitAppSetting : IAppSettings
    {
        // Fields
        private string fAppPath;
        private string fCodeDataPath;
        private string fCodeTablePath;
        private string fConnectionString;
        private CultureInfo fCulture;
        private string fCultureName;
        private string fDataXmlPath;
        private string fDBProvider;
        private string fEasySearch2Path;
        private string fEasySearchPath;
        private string fErrorPath;
        private int fIDStep;
        private string fModuleXmlPath;
        private string fSolutionPath;
        private string fSqlProvider;
        private string fUploadPath;
        private string fUploadVirtualPath;
        private string fXmlPath;
        private string fXsltPath;

        // Methods
        public AppToolkitAppSetting()
        {
            this.fDBProvider = "SQL Server";
            this.fSqlProvider = "SQL Server";
            this.fIDStep = 1;
        }

        public AppToolkitAppSetting(EasyWebConfigSection section)
        {
            this.fDBProvider = "SQL Server";
            this.fSqlProvider = "SQL Server";
            this.fIDStep = 1;
            this.fSolutionPath = section.SolutionPath;
            this.fConnectionString = section.ConnectionString;
            this.fDBProvider = section.DBProvider;
            this.fSqlProvider = section.SqlProvider;
            this.fIDStep = section.IDStep;
            this.fCultureName = section.CultureName;
            this.fCulture = new CultureInfo(this.fCultureName);
            this.fUploadPath = section.UploadPath;
            this.fUploadVirtualPath = section.UploadVirtualPath;
        }

        public void ReadSettings()
        {
            this.fXmlPath = Path.Combine(this.fSolutionPath, @"Xml\");
            this.fXsltPath = Path.Combine(this.fXmlPath, @"Project\");
            this.fDataXmlPath = Path.Combine(this.fXmlPath, @"Data\");
            this.fModuleXmlPath = Path.Combine(this.fXmlPath, @"Module\");
            this.fEasySearchPath = Path.Combine(this.fXmlPath, @"EasySearch\");
            this.fEasySearch2Path = Path.Combine(this.fXmlPath, @"EasySearch2\");
            this.fCodeTablePath = Path.Combine(this.fXmlPath, @"CodeTable\");
            this.fCodeDataPath = Path.Combine(this.fXmlPath, @"CodeData\");
            this.fErrorPath = Path.Combine(this.fSolutionPath, @"Error\");
            this.fAppPath = FileUtil.VerifyFilePath(System.Windows.Forms.Application.StartupPath);
        }

        // Properties
        public string AppPath
        {
            get
            {
                return this.fAppPath;
            }
        }

        public string CodeDataPath
        {
            get
            {
                return this.fCodeDataPath;
            }
        }

        public string CodeTablePath
        {
            get
            {
                return this.fCodeTablePath;
            }
        }

        public string ConnectionString
        {
            get
            {
                return this.fConnectionString;
            }
        }

        public CultureInfo Culture
        {
            get
            {
                return this.fCulture;
            }
        }

        public string CultureName
        {
            get
            {
                return this.fCultureName;
            }
        }

        public string DataXmlPath
        {
            get
            {
                return this.fDataXmlPath;
            }
        }

        public string DBProvider
        {
            get
            {
                return this.fDBProvider;
            }
        }

        public bool Debug
        {
            get
            {
                return false;
            }
        }

        public string EasySearch2Path
        {
            get
            {
                return this.fEasySearch2Path;
            }
        }

        public string EasySearchPath
        {
            get
            {
                return this.fEasySearchPath;
            }
        }

        public string ErrorPath
        {
            get
            {
                return this.fErrorPath;
            }
        }

        public int IDStep
        {
            get
            {
                return this.fIDStep;
            }
        }

        public bool IsShowException
        {
            get
            {
                return false;
            }
        }

        public int MaxExcelRecords
        {
            get
            {
                return 0;
            }
        }

        public string ModuleXmlPath
        {
            get
            {
                return this.fModuleXmlPath;
            }
        }

        public string SolutionPath
        {
            get
            {
                return this.fSolutionPath;
            }
        }

        public string SqlProvider
        {
            get
            {
                return this.fSqlProvider;
            }
        }

        public string UploadPath
        {
            get
            {
                return this.fUploadPath;
            }
        }

        public string UploadVirtualPath
        {
            get
            {
                return this.fUploadVirtualPath;
            }
        }

        public bool UseCache
        {
            get
            {
                return false;
            }
        }

        public bool UseInternalXslt
        {
            get
            {
                return false;
            }
        }

        public string XmlPath
        {
            get
            {
                return this.fXmlPath;
            }
        }

        public string XsltPath
        {
            get
            {
                return this.fXsltPath;
            }
        }
    }
}